package de.velvettear.squirrel.gui;

import android.app.Activity;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.widget.TextView;
import de.velvettear.squirrel.R;
import de.velvettear.squirrel.util.BluetoothHelper;

public class About extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.activity_about);
	   	    
	    setText();
	}

	private void setText() {
		TextView tv_version = (TextView) findViewById(R.id.about_tv_version_value);
		TextView tv_license = (TextView) findViewById(R.id.about_tv_license_value);
		
		tv_version.setText("v" + getVersionName() + " Build " + getVersionCode());
		tv_license.setMovementMethod(LinkMovementMethod.getInstance());
	}
	
	private String getVersionName() {
		String versionName = "";
		try {
			versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
		} catch (Exception e) {
			if (e.getMessage() != null) {
				Log.e("getVersionName()", e.getMessage());
			}
		}
		return versionName;
	}
	
	private String getVersionCode() {
		String versionCode = "";
		try {
			versionCode = String.valueOf(getPackageManager().getPackageInfo(getPackageName(), 0).versionCode);
		} catch (Exception e) {
			if (e.getMessage() != null) {
				Log.e("getVersionCode()", e.getMessage());
			}
		}
		return versionCode;
	}
		
}
